﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NewSubjectManager.aspx.cs" Inherits="ExamV5.StudyInfo.NewSubjectManager" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="../Image/examstyle.css" rel="stylesheet" type="text/css" />
    <link href="../Image/jquery.treeview.css" rel="stylesheet" type="text/css" />
    <link href="../layui/css/layui.css" rel="stylesheet" type="text/css" />

</head>
<body>
    <form id="form1" runat="server" class="layui-form">
        <div class="fl" style="background: #EFF1F7; width: 92%;">
            <p class="bread_nav">
                <img src="../Image/images/zy_position.png" />当前位置：<a href="../FrmMain.aspx">系统首页</a> > <a href="#">学习培训管理</a> > <a id="pageType" href="#">电子教材管理</a>
            </p>

            <asp:ScriptManager ID="SM" runat="server"></asp:ScriptManager>
            <asp:UpdatePanel runat="server" ID="UPPart" OnLoad="UPPart_Load">
                <ContentTemplate>


                    <!--主要内容-->
                    <div class="teaching_material">
                        <div class="material_tree">
                            <h1>教材信息管理</h1>
                            <div class="slie_tree">
                                <i class="bgfff"></i>
                                <asp:TreeView ID="TreeSubject" runat="server"
                                    ShowExpandCollapse="true"
                                    ImageSet="Custom"
                                    NoExpandImageUrl="~/Image/images/space.png"
                                    ExpandImageUrl="~/Image/images/jc_shouqi.png"
                                    CollapseImageUrl="~/Image/images/jc_zhankai.png"
                                    NodeStyle-Font-Size="14px"
                                    NodeStyle-Height="30"
                                    ShowLines="false"
                                    OnSelectedNodeChanged="TreeSubject_SelectedNodeChanged">
                                </asp:TreeView>
                            </div>
                        </div>
                        <div class="material_main all_tab">
                            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                                <ul class="layui-tab-title">
                                    <li class="layui-this" onclick="changeTile(this)">电子教材管理</li>
                                    <li onclick="changeTile(this)">教材类别管理</li>
                                </ul>
                                <div class="layui-tab-content tab_cont" id="tabContent">

                                    <div class="layui-tab-item layui-show">
                                        <%--<form class="layui-form">--%>
                                        <div class="lookup">
                                            <div class="layui-form-item">
                                                <div class="layui-input-inline w125">
                                                    <asp:DropDownList ID="DDLQuery" runat="server">
                                                        <asp:ListItem Value="a.SubjectName">教材名称</asp:ListItem>
                                                        <asp:ListItem Value="a.InputUnit">编制单位</asp:ListItem>
                                                        <asp:ListItem Value="a.MainCheckUser">编著作者</asp:ListItem>
                                                    </asp:DropDownList>
                                                    <%--<select>
                                                            <option value="1">教材名称</option>
                                                            <option value="2">教材名称</option>
                                                        </select>--%>
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <div class="layui-input-inline w200">
                                                    <asp:TextBox ID="txtQuery" runat="server" CssClass="layui-input radius5"></asp:TextBox>
                                                </div>
                                            </div>

                                            <asp:Button runat="server" ID="btnSelect" CssClass="layui-btn radius5 pd_lr34 bg_blue" Text="查询" OnClick="btnSelect_Click" />
                                            <asp:Button runat="server" ID="butAdd" OnClientClick="openJCModal('新增电子教材','');" CssClass="layui-btn radius5 pd_lr34 bg_orange" Text="新增教材" />

                                            <%--<input type="submit" class="layui-btn radius5 pd_lr34 bg_blue" value="查询" />--%>
                                            <%--<input type="submit" class="layui-btn radius5 pd_lr34 bg_orange" value="新增教材" />--%>
                                        </div>
                                        <div class="layui-form table_box">
                                            <asp:GridView ID="DataGridInfo" runat="server" AllowPaging="True"
                                                OnPageIndexChanging="DataGridInfo_PageIndexChanging"
                                                AutoGenerateColumns="False" CellPadding="10" BorderWidth="1px" Width="100%"
                                                CssClass="layui-table" BackColor="White" PageSize="4"
                                                AllowSorting="True" OnSorting="DataGridInfo_Sorting"
                                                OnRowDataBound="DataGridInfo_RowDataBound"
                                                DataKeyNames="ID,SubjectName,CreatUser,EditUserCode,BookImage"
                                                OnRowDeleting="DataGridInfo_RowDeleting">
                                                <HeaderStyle Font-Bold="True" HorizontalAlign="Center" BackColor="#e1e7f9"></HeaderStyle>
                                                <Columns>
                                                    <asp:TemplateField HeaderText="教材封面">
                                                        <ItemTemplate>
                                                            <asp:Image ID="ImgBook" runat="server" Width="90" Height="110" BorderWidth="0" />
                                                        </ItemTemplate>
                                                        <ItemStyle CssClass="jc_coverimg" />
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="教材信息">

                                                        <ItemTemplate>
                                                            <div>
                                                                <p>教材名称：<asp:Label ID="labSubjectName" runat="server" Text='<%# Bind("SubjectName") %>'> </asp:Label></p>
                                                                <p>编制单位：<asp:Label ID="labInputUnit" runat="server" Text='<%# Bind("InputUnit") %>'></asp:Label></p>
                                                                <p>编著作者：<asp:Label ID="labMainCheckUser" runat="server" Text='<%# Bind("MainCheckUser") %>'> </asp:Label></p>
                                                                <p>编制日期：<asp:Label ID="labInputTime" runat="server" Text='<%# Bind("InputTime") %>'> </asp:Label></p>
                                                            </div>
                                                        </ItemTemplate>
                                                        <ItemStyle CssClass="tl jc_xx" />
                                                    </asp:TemplateField>
                                                    <asp:BoundField DataField="ReadNum" HeaderText="浏览次数" SortExpression="ReadNum">
                                                        <ItemStyle HorizontalAlign="Center" />
                                                    </asp:BoundField>
                                                    <asp:TemplateField HeaderText="操作">
                                                        <ItemTemplate>
                                                            <p>
                                                                <asp:LinkButton ID="LBEditBook" runat="server" CausesValidation="False" Text="编辑教材"></asp:LinkButton>
                                                            </p>
                                                            <p>
                                                                <asp:LinkButton ID="LBEditItem" runat="server" CausesValidation="False" Text="编辑章节"></asp:LinkButton>
                                                            </p>
                                                            <p>
                                                                <asp:LinkButton ID="LBDel" runat="server" CausesValidation="False" CommandName="Delete" Text="删除"></asp:LinkButton>
                                                            </p>
                                                        </ItemTemplate>
                                                        <ItemStyle HorizontalAlign="Center" />
                                                    </asp:TemplateField>
                                                </Columns>
                                                <PagerStyle HorizontalAlign="Right" />
                                            </asp:GridView>


                                            <div class="table_page tr">
                                                <asp:Label ID="labRescordCount" runat="server"></asp:Label>
                                                <asp:LinkButton ID="LBFirstPage" runat="server" OnClick="LBFirstPage_Click">首页</asp:LinkButton>
                                                <asp:LinkButton ID="LBPrevPage" runat="server" OnClick="LBPrevPage_Click">上一页</asp:LinkButton>
                                                <asp:LinkButton ID="LBNextPage" runat="server" OnClick="LBNextPage_Click">下一页</asp:LinkButton>
                                                <asp:LinkButton ID="LBLastPage" runat="server" OnClick="LBLastPage_Click">尾页</asp:LinkButton>
                                            </div>
                                        </div>
                                        <%--</form>--%>
                                    </div>


                                    <div class="layui-tab-item">
                                        <%--<form class="layui-form">--%>
                                        <div class="jc_lbgl">
                                            <p class="register_tips">
                                                <img src="../Image/images/zc_zhuyi.png" />学院基本信息可以不填，可以直接下一步~
                                                    <asp:Label ID="labID" runat="server" Text="0" Visible="false"></asp:Label>
                                            </p>
                                            <!--注册流程图-->
                                            <div class="zhuce_m">
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label w110"><span class="xing">*</span>上级类别名称</label>
                                                    <div class="layui-input-inline w330">
                                                        <asp:DropDownList ID="DDLUPFolder" runat="server"></asp:DropDownList>
                                                    </div>
                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label w110"><span class="xing">*</span>教材类别名称</label>
                                                    <div class="layui-input-inline w330">
                                                        <asp:TextBox ID="txtFolderName" runat="server" CssClass="layui-input radius5" MaxLength="50"></asp:TextBox>
                                                    </div>
                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label w110"><span class="xing">*</span>设置浏览部门</label>
                                                    <div class="layui-input-inline w330">
                                                        <textarea class="layui-input radius5" style="height: 80px !important;" id="txtBrowDeptName" name="txtBrowDeptName" readonly><%=strBrowDeptName%></textarea>
                                                        <input id="txtBrowDeptID" name="txtBrowDeptID" type="hidden" value="<%=strBrowDeptID%>">
                                                    </div>
                                                    <a href="#">
                                                        <img src="../Image/images/jc_more.png" onclick="ShowBDeptList('txtBrowDeptName','txtBrowDeptID');" />
                                                    </a>
                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label w110"><span class="xing">*</span>设置浏览人员</label>
                                                    <div class="layui-input-inline w330">
                                                        <textarea class="layui-input radius5" style="height: 80px !important;" id="txtBrowUserName" name="txtBrowUserName" readonly><%=strBrowUserName%></textarea>
                                                        <input id="txtBrowUserCode" name="txtBrowUserCode" type="hidden" value="<%=strBrowUserCode%>">
                                                    </div>
                                                    <a href="#">
                                                        <img src="../Image/images/jc_more.png" />
                                                    </a>
                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label w110"><span class="xing">*</span>设置编辑人员</label>
                                                    <div class="layui-input-inline w330">
                                                        <textarea class="layui-input radius5" style="height: 80px !important;" id="txtEditUserName" name="txtEditUserName" readonly><%=strEditUserName%></textarea>
                                                        <input id="txtEditUserCode" name="txtEditUserCode" type="hidden" value="<%=strEditUserCode%>">
                                                    </div>
                                                    <a href="#">
                                                        <img src="../Image/images/jc_more.png" />
                                                    </a>
                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label w110"><span class="xing">*</span>教材类别排序</label>
                                                    <div class="layui-input-inline w330">
                                                        <asp:TextBox ID="txtSortInfo" runat="server" CssClass="layui-input radius5"
                                                            MaxLength="5"
                                                            onKeypress="javascript:if (event.keyCode &lt; 48 || event.keyCode &gt; 57) event.returnValue = false;"
                                                            onpaste="return false"></asp:TextBox>
                                                    </div>
                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label w110"></label>
                                                    <div class="layui-input-block">
                                                        <asp:Button ID="butDefault" runat="server" Text="新  增" CssClass="layui-btn radius5 bg_blue w120"
                                                            OnClientClick="return CheckData();" OnClick="butDefault_Click" />
                                                        <asp:Button ID="butDel" runat="server" Text="删  除" CssClass="layui-btn radius5 bg_c8c8c8 w120" OnClick="butDel_Click" />
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <%--</form>--%>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--主要内容end-->


                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </form>
    <script type="text/javascript" src="../Image/jquery.min.js"></script>
    <script type="text/javascript" src="../layui/layui.all.js"></script>
    <script type="text/javascript" src="../Image/jquery.treeview.js"></script>
    <script type="text/javascript" src="../Image/jquery.cookie.js"></script>
    <script>
        var type = 0
        $(document).ready(function () {
            type = request.QueryString("type");
            if (type == undefined || type == null) type = 0;
            opentab();

            $("#red").treeview({
                animated: "fast",
                collapsed: true,
                unique: true,
                persist: "cookie",
                toggle: function () {
                    window.console && console.log("%o was toggled", this);
                }
            });

        });

        function renderForm() {
            layui.use('form', function () {
                var form = layui.form;
                form.render();
            });
        }

        function openJCModal(title, id) {
            layer.open({
                type: 2,
                title: title,
                content: ['NewSunjectManagerEdit.aspx?ID=' + id, 'no'], //不允许出现滚动条
                area: ['600px', '700px'],
                end: function () {
                    $('#btnSelect').click();
                }
            });
        }

        function openZJModal(title, id) {
            if (id == undefined || id.length == 0) id = 0;
            layer.open({
                type: 2,
                title: title,
                content: ['NewSunjectManagerZJEdit.aspx?ID=0&BookID=' + id, 'no'], //不允许出现滚动条
                area: ['940px', '720px'],
            });
        }

        function changeTile(_this) {
            $("#pageType").text($(_this).text());
            var index = $(_this).parent().find('li').index(_this);
            if (index >= 0) type = index;
        }

        function opentab() {
            if (type == 1) {
                $("#pageType").text('教材类别管理');
            } else {
                $("#pageType").text('电子教材管理');
            }
            $('.layui-tab-title li').removeClass('layui-this');
            $('.layui-tab-title li:eq(' + type + ')').addClass('layui-this');

            $('#tabContent .layui-tab-item').removeClass('layui-show');
            $('#tabContent .layui-tab-item:eq(' + type + ')').addClass('layui-show');
            renderForm();
        }

        function CheckData() {

            if (document.getElementById("DDLUPFolder").value == "") {
                alert("上级类别名称不可以为空！");
                document.getElementById("DDLUPFolder").focus();
                return false;
            }

            if (document.getElementById("txtFolderName").value == "") {
                alert("教材类别名称不可以为空！");
                document.getElementById("txtFolderName").focus();
                return false;
            }
            if (document.getElementById("txtSortInfo").value == "") {
                alert("教材类别排序不可以为空！");
                document.getElementById("txtSortInfo").focus();
                return false;
            }

            return true;
        }

        function ShowBUserList(txtBrowUserName, txtBrowUserCode) {
            var strusername = "";
            var strname = "";
            strname = document.getElementById("txtBrowUserName").value;
            strusername = document.getElementById("txtBrowUserCode").value;
            strtmpusers = textUser(strusername, strname, 'B');
            if (strtmpusers != "") {
                strtmpusers = strtmpusers.split("_");
                document.getElementById("txtBrowUserCode").value = strtmpusers[0];
                document.getElementById("txtBrowUserName").value = strtmpusers[1];

            }
        }

        function ShowEUserList(txtEditUserName, txtEditUserCode) {
            var strusername = "";
            var strname = "";
            strname = document.getElementById("txtEditUserName").value;
            strusername = document.getElementById("txtEditUserCode").value;
            strtmpusers = textUser(strusername, strname, 'E');
            if (strtmpusers != "") {
                strtmpusers = strtmpusers.split("_");
                document.getElementById("txtEditUserCode").value = strtmpusers[0];
                document.getElementById("txtEditUserName").value = strtmpusers[1];

            }
        }

        function textUser(usernames, names, strEB) {
            var strURL = "../ManagSys/FrmSelectUser.aspx?EB=" + strEB + "&TypeValue=B&strFlag=A&ID=" + document.getElementById("txtID").value;
            var obj = new Object();
            obj.username = usernames;
            obj.name = names;

            var iWidth = 620;
            var iHeight = 650;
            var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
            var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
            var strvalue = window.open(strURL, "", "height=" + iHeight + ", width=" + iWidth + ", top=" + iTop + ", left=" + iLeft + ",status=no,toolbar=no,menubar=no,location=no");
            if (strvalue == undefined) {
                return window.returnValue;
            }
            else if (strvalue != "")
                return strvalue;
            else
                return false;
        }

        function ShowBDeptList(txtBrowDeptName, txtBrowDeptID) {
            var strusername = "";
            var strname = "";
            strname = document.getElementById("txtBrowDeptName").value;
            strusername = document.getElementById("txtBrowDeptID").value;
            strtmpusers = textDept(strusername, strname);
            //if (strtmpusers != "") {
            //    strtmpusers = strtmpusers.split("_");
            //    document.getElementById("txtBrowDeptID").value = strtmpusers[0];
            //    document.getElementById("txtBrowDeptName").value = strtmpusers[1];
            //}
        }

        function textDept(usernames, names) {
            var strURL = "../CommonPage/UnitChoose.aspx?Flag=T&ID=" + document.getElementById("txtID").value;
            layer.open({
                type: 2,
                title: title,
                content: ['../CommonPage/UnitChoose.aspx', 'no'], //不允许出现滚动条
                area: ['620px', '650px'],
            });

            //var obj = new Object();
            //obj.username = usernames;
            //obj.name = names;

            //var iWidth = 620;
            //var iHeight = 600;
            //var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
            //var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
            //var strvalue = window.open(strURL, "", "height=" + iHeight + ", width=" + iWidth + ", top=" + iTop + ", left=" + iLeft + ",status=no,toolbar=no,menubar=no,location=no");
            //if (strvalue == undefined) {
            //    return window.returnValue;
            //}
            //else if (strvalue != "")
            //    return strvalue;
            //else
            //    return false;
        }

        var request =
            {
                QueryString: function (val) {
                    var uri = window.location.search;
                    var re = new RegExp("" + val + "=([^&]*)", "ig");
                    return ((uri.match(re)) ? (uri.match(re)[0].substr(val.length + 1)) : null);
                }
            }

    </script>
</body>
</html>
